package com.ohc.test.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;

public class Client {

    public static void main(String[] args) {
        ManSinger zjl = new ManSinger("zjl");
        Singer proxy = (Singer) Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(), new Class[]{
                        Singer.class
                },
                new InvocationHandler() {
                    @Override
                    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
                        System.out.println("before");
                        method.invoke(zjl);
                        System.out.println("after");
                        return null;
                    }
                });
        proxy.sing();
    }
}
